# Android environment
import os
import unittest

import self as self
import yaml
from appium import webdriver
from selenium.webdriver.support.wait import WebDriverWait


class DriverCreat:

    def __init__(self):
        curPath = os.path.abspath(os.path.dirname(__file__))
        rootPath = os.path.split(curPath)[0]
        desired_caps = yaml.load(open(f'{rootPath}/config/appiumInfo.yaml', 'r', encoding='utf-8').read(),Loader=yaml.FullLoader)
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
        self.driver.step_with_screenshot = True
        self.driver.implicitly_wait(15)

    def init_webdriver(self):
        return self.driver

    def quit(self):
        self.driver.quit()
